package com.zwps.biz.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.zwps.biz.dal.constant.TableNameConstant;
import com.zwps.common.core.mybatis.interceptor.ThreadLocalOnceScopeDataInterceptor;
import com.zwps.common.core.mybatis.interceptor.ThreadLocalScopeDataInterceptor;
import com.zwps.common.core.mybatis.interceptor.UserActionValueFillInterceptor;

@Configuration
public class SystemProcessDataTableConfig {

    /**
     * 注册表字段字段添加当前用户信息
     * 
     * @Title: newUserActionValueFillInterceptor
     * @Description:
     * @param mybatisPlusInterceptor
     * @return UserActionValueFillInterceptor
     * @author lyh
     * @date 2023年5月26日 下午5:01:51
     */
    @Bean
    public UserActionValueFillInterceptor newSystemUserActionValueFillInterceptor(
            MybatisPlusInterceptor mybatisPlusInterceptor) {
        UserActionValueFillInterceptor interceptor = new UserActionValueFillInterceptor(mybatisPlusInterceptor);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_DEPT);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_ROLE);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_PERMISSION_ROLE_PAGE);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_PERMISSION_PAGE);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_USER_ROLE);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_USER);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_REGION);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_PERMISSION_API);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.SYS_DICT);

        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.FILE_RECORD);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.FILE_RECORD_BIZ);
        interceptor.addTableNameToInsertAndUpdate(TableNameConstant.FILE_RECORD_BIZ_SETTING);
        return interceptor;
    }

//    @Bean
//    public GlobalScopeDataInterceptor newSystemGlobalScopeDataInterceptor(MybatisPlusInterceptor mybatisPlusInterceptor) {
//        GlobalScopeDataInterceptor interceptor = new GlobalScopeDataInterceptor(mybatisPlusInterceptor);
//        return interceptor;
//    }

    @Bean
    public ThreadLocalOnceScopeDataInterceptor newSystemThreadLocalOnceScopeDataInterceptor(
            MybatisPlusInterceptor mybatisPlusInterceptor) {
        return new ThreadLocalOnceScopeDataInterceptor(mybatisPlusInterceptor);
    }

    @Bean
    public ThreadLocalScopeDataInterceptor newSystemThreadLocalScopeDataInterceptor(
            MybatisPlusInterceptor mybatisPlusInterceptor) {
        return new ThreadLocalScopeDataInterceptor(mybatisPlusInterceptor);
    }
}
